#!/bin/bash

rm -rf output

mkdir output1
echo "编译中... "
go build -o supplier main.go

mv supplier output/
mkdir -p output/config/plugin

SUPPLIER_HOME=`pwd`
PLUGIN_DIR="./internal/plugin"

for file in "$PLUGIN_DIR"/*; do
  if [ -d "$file" ]; then
    echo "$file"
    for f in "$file"/*; do
      if [ -f "$f" ]; then
        filename=`basename $file`
        echo "编译.so 文件 $file"
        go build -buildmode=plugin -o "$filename".so $f
        mv "$filename".so "$SUPPLIER_HOME"/output/config/plugin
      fi
    done
  fi
done

echo "编译完成"